import binascii
import functools


def hex2dec(string_num):
    return str(int(string_num.upper(), 16))


def compare(a, b):
    for i in range(4):
        if data.index(a[i]) > data.index(b[i]):
            return 1
        elif data.index(a[i]) < data.index(b[i]):
            return -1
        else:
            continue
def right(data):
    print(data)
    result = []
    result.append(''.join(data))
    i = 0
    while i < 3:
        temp = []
        temp.insert(0, data[3])
        temp.insert(1, data[2])
        temp.insert(2, data[0])
        temp.insert(3, data[1])
        result.append(''.join(temp))
        data = temp
        i = i + 1
    L = ''
    F = ''
    sorted_list = sorted(result)
    for eachstr in sorted_list:
        L = L + eachstr[-1]
        F = F + eachstr[0]
    return L

f = open('../../README.en.md', 'rb')
print(bytes.decode(binascii.hexlify(f.read()), encoding='utf8'))
data = [-1j, 1j, -1, 1]
# print(right([1, -1j, 1, 1j]))
# import numpy
# print(numpy.fromfile('../../README.en.md',dtype =numpy.int8))

import random

seed = "01"
sa = []
for i in range(24):
    sa.append(random.choice(seed))
salt = ''.join(sa)
print(salt)
dict_= {'0':-1,'1':1}
res =[]
for i in range(0,24,3):
    temp =complex(dict_[salt[i]],dict_[salt[i+1]])/complex(1,1)
    if temp.real!=0:
        ans=dict_[salt[i + 2]]*1j
    else:
        ans= dict_[salt[i + 2]]
    if temp.imag==0 and temp.real==1:
        temp1="0"
    elif temp.imag == 0 and temp.real == -1:
        temp1 = "1"
    elif temp.imag == 1 and temp.real == 0:
        temp1 = "2"
    else:
        temp1 = "3"
    res.append(temp1)
    # res.append(ans)
print(res)
for i in range(0,16,4):
    temp = [res[i],res[i+1],res[i+2],res[i+3]]
    print(temp,right(temp))
